#include<sys/types.h>
#include<string.h>
#include<stdio.h>
#include<sys/stat.h>
#include<unistd.h>
#include<fcntl.h>
#include<stdlib.h>
#include<sys/wait.h>

int main()
{
    int fi = mkfifo("fifo",0644);
    if(fi < 0)
    {
      perror("mkfifo is error");
      exit(1);
    }
  int fd = open("fifo",O_RDONLY);
  while(1)
  {
    char buff[64] = {'\0'};
    int size = read(fd,buff,sizeof(buff)-1);
    buff[size-1] = 0;
    if(size)
    {
      if(strcmp(buff,"ls") == 0)
      {
        if(fork() == 0)
        {
          execl("/usr/bin/ls","ls","-l",NULL);
          perror("execl is error");
          exit(1);
        }
      }
      printf("client say:%s\n",buff);
    }
  }
  return 0;
}
